package admin_rule_types

import "oc_saas/internal/model/base"

// 规则参数
type Route struct {
	Name      string `json:"name" validate:"ocPerms"`
	Path      string `json:"path" validate:"ocPath"`
	Component string `json:"component" validate:"ocVue"`
	Redirect  string `json:"redirect" validate:"ocPath"`
	IsHome    bool   `json:"is_home"`
	Meta      Meta   `json:"meta"`
}
type Meta struct {
	Icon        string `json:"icon" validate:"min=0,max=20"`
	Title       string `json:"title" validate:"min=2,max=10,required"`
	IsLink      string `json:"isLink"`
	IsHide      bool   `json:"isHide"`
	IsFull      bool   `json:"isFull"`
	IsAffix     bool   `json:"isAffix"`
	IsKeepAlive bool   `json:"isKeepAlive"`
}

type Api struct {
	Type string `json:"type" validate:"ocReqType"`
	Path string `json:"path" validate:"ocPath"`
}

type Rule struct {
	base.IDColumn
	Sort  int    `json:"sort" validate:"min=0,max=10000"`
	PID   uint   `json:"pid"`
	Name  string `json:"name"`
	Perms string `json:"perms" validate:"ocPerms"`
	Link  string `json:"-"`
	Type  string `json:"type" `
	Route Route  `json:"route,omitempty" `
	Api   Api    `json:"api,omitempty"`
}

// 规则返回
type RuleBody struct {
	base.IDColumn
	Sort        int    `json:"sort" validate:"min=0,max=10000"`
	PID         uint   `json:"pid"`
	Name        string `json:"name"`
	Perms       string `json:"perms" validate:"ocPerms"`
	Type        string `json:"type" `
	Path        string `json:"path"`
	Component   string `json:"component"`
	Title       string `json:"title"`
	IsLink      string `json:"is_link"`
	IsHide      bool   `json:"is_hide"`
	IsFull      bool   `json:"is_full"`
	IsAffix     bool   `json:"is_affix"`
	IsKeepAlive bool   `json:"is_keep_alive"`
	IsHome      bool   `json:"is_home"`
	Redirect    string `json:"redirect"`
	Icon        string `json:"icon"`
	ApiType     string `json:"api_type"`
	ApiPath     string `json:"api_path"`
}

// 规则列表请求参数
type RuleListParamsReq struct {
	RuleType string `form:"type"`
}
